﻿#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;


class Solution
{
public:
    // 873. 最长的斐波那契子序列的长度
    int lenLongestFibSubseq(vector<int>& arr)
    {
        int n = arr.size();

        unordered_map<int, int> hash;
        for (int i = 0; i < n; i++)
            hash[arr[i]] = i;
        vector<vector<int>> dp(n, vector<int>(n, 2));

        int ret = 2;
        for (int j = 2; j < n; j++)
        {
            for (int i = 1; i < j; i++)
            {
                int diff = arr[j] - arr[i];
                if (diff < arr[i] && hash.count(diff))
                {
                    dp[i][j] = dp[hash[diff]][i] + 1;
                    ret = max(dp[i][j], ret);
                }
            }
        }
        return ret < 3 ? 0 : ret;
    }
};

int main()
{

    return 0;
}